package com.dongyun.loraweb.entity;

import java.util.UUID;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import javax.persistence.PrePersist;
import javax.validation.constraints.Pattern;

@MappedSuperclass
public class DomainObject {
	@Id
	@Column(length=32)
	@Pattern(regexp="[a-z0-9]{32}",message="uuid只能是包含a-z0-9的32位字符")
	protected String uuid;
	
	@PrePersist
	public void initUuid(){
		uuid=UUID.randomUUID().toString().replace("-", "");
	}

	public String getUuid() {
		return uuid;
	}

	public void setUuid(String uuid) {
		this.uuid = uuid;
	}
}
